import axios from "./index";

/** database table clumns */
export function fetchTableAndColumnsApi(tableId) {
    var params = {tableId: tableId};

    return axios.get('/project/tableAndColumns',{
        params: params
    });
}

export function fetchTableListApi(projectId, from) {
    var params = {projectId: projectId, from};

    return axios.get('/project/fetchTableListByProjectHasDb',{
        params: params
    });
}


/** field 成员变量 */
export function addFieldInfoApi(fileObj) {
    return axios.post('/project/fileFieldInfo', fileObj);
}

export function modifyFieldInfoApi(fileObj) {
    return axios.put('/project/fileFieldInfo', fileObj);
}

export function removeFieldInfoApi(id) {
    return axios.delete('/project/fileFieldInfo', {params:{id: id}});
}



/** project module **/
export function projectModuleListApi(projectId) {
    var params = {projectId: projectId};

    return axios.get('/proProject/projectModuleList',{
        params: params
    });
}

export function addModuleApi(moduleObj) {
    return axios.post('/proProject/moduleInfo', moduleObj);
}

export function removeModuleApi(moduleId) {
    return axios.delete('/proProject/moduleInfo', {params:{id: moduleId}});
}

export function modifyModuleApi(moduleObj) {
    return axios.put('/proProject/moduleInfo', moduleObj);
}


/** 微服务 */
export function projectMicroServiceListApi(projectId) {
    let params = {projectId: projectId};
    return axios.get('/proProject/projectMicroServiceList',{
        params: params
    });
}

export function addMicroServiceApi(moduleObj) {
    return axios.post('/proProject/microServiceInfo', moduleObj);
}

export function removeMicroServiceApi(moduleId) {
    return axios.delete('/proProject/microServiceInfo', {params:{id: moduleId}});
}

export function modifyMicroServiceApi(moduleObj) {
    return axios.put('/proProject/microServiceInfo', moduleObj);
}



/** file */
export function fetchProjectFileTreeApi(projectId, packageType, moduleId) {

    var params = {projectId: projectId, packageType: packageType, moduleId: moduleId};

    return axios.get('/project/fileTree',{
        params: params
    });
}

export function fetchFileInfoApi(fileId) {
    var params = {fileId: fileId};
    return axios.get('/project/fileInfo',{
        params: params
    });
}

export function modifyFileInfoApi(fileObj) {
    return axios.put('/project/fileInfo', fileObj);
}

export function addFileInfoApi(fileObj) {
    return axios.post('/project/fileInfo', fileObj);
}

export function delFileInfoApi(fileId) {
    var params = {fileId: fileId};
    return axios.delete('/project/fileInfo', {
        params: params
    });
}

/*
 * @param projectId
 * @param fileType controller|service|vo|dao|domain
 */
export function fileListApi(projectId, fileType) {
    return axios.get('/project/fileList', {
        params: {projectId: projectId, fileType: fileType}
    });
}

/** function */
export function modifyFunctionApi(funcObj) {
    return axios.put('/project/functionInfo', funcObj);
}

export function addFunctionApi(funcObj) {
    return axios.post('/project/functionInfo', funcObj);
}

export function delFunctionApi(funId) {
    return axios.delete('/project/functionInfo', { params:{funId:funId}});
}

export function getFunctionApi(funId) {
    return axios.get('/project/functionInfo', { params:{funId:funId}});
}

export function fetchFunsByFileId(fileId) {
    var params = {fileId: fileId};
    return axios.get('/project/fetchFunsByFileId',{
        params: params
    });
}

/** function params */
export function addFunArgByFieldIdApi(paramsObj) {
    return axios.post('/project/addFunArgByFieldId', paramsObj);
}

export function addFunArgApi(paramsObj) {
    return axios.post('/project/funArg', paramsObj);
}

export function modifyFunArgApi(paramsObj) {
    return axios.put('/project/funArg', paramsObj);
}

export function listFunArgApi(funId) {
    var params = {funId: funId};

    return axios.get('/project/listFunArg',{
        params: params
    });
}

export function removeArgApi(argId) {
    return axios.delete('/project/funArg', {params:{argId: argId}});
}

/** validate return */
export function validateListApi(proId) {
    var params = {proId: proId};

    return axios.get('/project/validateList',{
        params: params
    });
}




/** function return */

